<template>
	<view class="courseDetail-content">
		<view class="detail-body">
			<view class="detail-content">
				<view class="detail-image">
					<image src="../../static/index/course.png" mode=""></image>
				</view>
				<view class="detail-text">
					<view class="detail-name">科一科四技巧答案（图表学习法全套解析）</view>
					<view class="detail-price">￥39.90</view>
					<view class="detail-tips">通关答案</view>
				</view>
				<view class="course-text">
					<view class="text-item">
						<view>终生享用</view>
						<view>有效期</view>
					</view>
					<view class="text-item">
						<view>65课时</view>
						<view>课时数</view>
					</view>
					<view class="text-item">
						<view>1488人</view>
						<view>购买量</view>
					</view>
				</view>
				<view class="course-list">
					<u-tabs :list="list" active-color='#2AC092' :is-scroll="false" :current="current"
						@change="change"></u-tabs>
					<scroll-view class="directory" scroll-y="true" v-if="current == 0">
						<view class="directory-item" v-for="(item,index) in dataList" :key="index">
							<view class="directory-title">
								<view class="period">第{{item.period}}课时</view>
								<view class="directory-name">{{item.title}}</view>
							</view>
							<view class="fun-box" v-if="item.status == 0">{{item.text}}</view>
							<view class="islock" v-if="item.status == 1">
								<image :src="item.text" mode=""></image>
							</view>
						</view>
					</scroll-view>
					<view class="blurb" v-if="current == 1 && courseType == 1">
						课程详情可由后台以图文形式编辑修改，课程详情可 由后台以图文形式编辑修改课程详情可由后台以图文 形式编辑修改。
					</view>
					<view class="blurb" v-if="current == 1 && courseType == 2">
						<scroll-view class="directory" scroll-y="true">
							<view class="directory-item" v-for="(item,index) in practice" :key="index">
								<view class="directory-title">
									<view class="directory-name">{{item.title}}</view>
								</view>
								<view class="fun-box1">立即练习</view>
							</view>
						</scroll-view>
					</view>
				</view>
				<view class="buy-box" v-if="courseType == 1">
					<view class="buy-price">付款: <span>￥39.90</span></view>
					<u-button shape="circle" :custom-style="customStyle" @click="gotoBuy">立即购买</u-button>
				</view>
				<view class="buy-box1" v-if="courseType == 2">
					<view class="down-box">
						<image src="../../static/index/wd.png" mode=""></image>
						<view>文档下载</view>
					</view>
					<view class="down-box">
						<image src="../../static/index/dayin.png" mode=""></image>
						<view>文档打印</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				customStyle: {
					background: '#2AC092',
					color: '#fff'
				},
				list: [{
					name: '课程目录'
				}, {
					name: '课程简介'
				}],
				current: 0,
				practice:[{
						period: '1',
						title: '禁令标识技巧',
					},
					{
						period: '2',
						title: '禁令标识技巧',
					},
					{
						period: '3',
						title: '禁令标识技巧',
					},
					{
						period: '4',
						title: '禁令标识技巧',
					}
				],
				dataList: [{
						period: '1',
						title: '禁令标识技巧',
						status: 0,
						text: '试看2分钟'
					},
					{
						period: '2',
						title: '禁令标识技巧',
						status: 1,
						text: '../../static/index/lock.png'
					},
					{
						period: '3',
						title: '禁令标识技巧',
						status: 1,
						text: '../../static/index/lock.png'
					},
					{
						period: '4',
						title: '禁令标识技巧',
						status: 1,
						text: '../../static/index/lock.png'
					}
				],
				courseType: 0
			}
		},
		onLoad(e) {
			this.courseType = e.type
			if (e.type == 1) {
				this.list = [{
					name: '课程目录'
				}, {
					name: '课程简介'
				}]
			} else if (e.type == 2) {
				this.list = [{
					name: '课程目录'
				}, {
					name: '写真练习'
				}]
			}
		},
		methods: {
			change(index) {
				this.current = index;
			},
			gotoBuy() {
				uni.navigateTo({
					url: '/pagesA/confirmOrder/index'
				})
			}
		}
	}
</script>

<style lang="scss">
	.detail-image {
		width: 100vw;
		height: 420rpx;

		>image {
			width: 100%;
			height: 100%;
		}
	}

	.detail-text {
		padding: 30rpx;
		border-bottom: 1rpx solid #E6E6E6;
		background-color: #fff;

		.detail-name {
			font-size: 34rpx;
		}

		.detail-price {
			font-size: 36rpx;
			color: #FF4D4D;
			margin: 20rpx 0;
		}

		.detail-tips {
			font-size: 24rpx;
			color: #2AC092;
			padding: 10rpx;
			background-color: #DEFCF3;
			border-radius: 10rpx;
			width: max-content;
			border: 1rpx solid #2AC092;
		}
	}

	.course-text {
		display: flex;
		background-color: #fff;
		padding: 30rpx;
		justify-content: space-between;


		.text-item {
			text-align: center;

			>view:first-child {
				font-size: 26rpx;
				margin-bottom: 10rpx;
			}

			>view:nth-child(2) {
				font-size: 22rpx;
				color: #999999;
			}
		}

	}

	.course-list {
		margin-top: 20rpx;

		.directory {
			height: 30vh;
			background-color: #fff;
		}

		.directory-item {
			display: flex;
			justify-content: space-between;
			padding: 30rpx;
			border-bottom: 1rpx solid #F5F5F5;

			.directory-title {
				display: flex;
				align-items: center;

				.period {
					color: #2AC092;
					border: 1rpx solid #2AC092;
					background-color: #DEFCF3;
					padding: 10rpx 15rpx;
					border-radius: 10rpx;
					font-size: 22rpx;
				}

				.directory-name {
					margin-left: 20rpx;
					font-size: 30rpx;
				}
			}

			.fun-box {
				color: #fff;
				background-color: #FFA23B;
				border-radius: 25rpx;
				padding: 10rpx 15rpx;
			}
			.fun-box1 {
				color: #fff;
				background-color: #2AC092;
				border-radius: 25rpx;
				padding: 10rpx 15rpx;
			}

			.islock {
				width: 40rpx;
				height: 40rpx;

				>image {
					width: 100%;
					height: 100%;
				}
			}
		}
	}

	.buy-box {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 30rpx;
		position: fixed;
		bottom: 0;
		background-color: #fff;
		width: 100%;

		.buy-price {
			font-size: 28rpx;

			>span {
				font-size: 36rpx;
				color: #FF4D4D;
			}
		}
	}
	
	.buy-box1 {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 30rpx 150rpx;
		position: fixed;
		bottom: 0;
		background-color: #fff;
		width: 100%;
	
		.down-box{
			display: flex;
			>image{
				width: 36rpx;
				height: 36rpx;
			}
		}
	}
</style>